package com.uchedao.vehicledetection.utils;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.uchedao.vehicledetection.R;

/**
 * @ClassName: ActionBarFactory
 * @Description: actionbar工厂
 * @date 2014-10-13 下午1:48:19
 * 
 */
public class ActionBarFactory {



	public View initActionbarForUnRight(final Context context,
										String title, View.OnClickListener titleOnClick,View.OnClickListener saveOnClick) {
		View view = LayoutInflater.from(context).inflate(
				R.layout.view_actionbar_main, null);
		TextView tv = (TextView) view
				.findViewById(R.id.tv_title_name);
		tv.setText(title);

		TextView back = (TextView) view
				.findViewById(R.id.title_back);
		back.setVisibility(View.GONE);
//		back.setOnClickListener(titleOnClick);

		TextView save = (TextView) view
				.findViewById(R.id.tv_right_save);
		save.setVisibility(View.VISIBLE);
		save.setOnClickListener(saveOnClick);

		initActionbarForCustomSearch(context, view);
		return view;
	}

	public void initActionbarForCustomSearch(Context context, View view) {
		Activity activity = (Activity) context;
		activity.getActionBar().setDisplayShowTitleEnabled(false);// 去掉原始ActionBar自带的标题
		activity.getActionBar().setDisplayShowHomeEnabled(false);
		activity.getActionBar().setDisplayShowCustomEnabled(true);// 设置显示自定义布局
		activity.getActionBar().setCustomView(view);
	}

}
